<?php

namespace App\Http\Requests\Logic\User;

use Illuminate\Support\Facades\Auth;
use Illuminate\Foundation\Http\FormRequest;

class BindProject extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
    	$user = Auth::user();
    	if ($user->hasCompany()) {
    		return true;
		}
        return false;
    }

	/**
	 * 定义验证规则
	 *
	 * Date: 2018/5/30
	 * @author George
	 * @return array
	 */
    public function rules()
    {
        return [
			'user_id' => 'required',
			'projects_id' => 'nullable|array',
        ];
    }

	/**
	 * 定义错误提示信息
	 *
	 * Date: 2018/5/30
	 * @author George
	 * @return array
	 */
	public function messages()
	{
		return [
			'user_id.required' => '请选择用户',
			'projects_id.array' => '指定的项目集合有误',
		];
    }
}
